package org.inspire.model;

import java.math.BigDecimal;
import java.util.Properties;

import org.compiere.model.CalloutEngine;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.MTax;
import org.compiere.util.Env;

public class CalloutPayment  extends CalloutEngine{
	
	public String amounts(Properties ctx, int WindowNo, GridTab mTab, GridField mField, 
			Object value, Object oldValue)
	{
		
		//Withholding Tax
		Integer taxID = (Integer)mTab.getValue("C_Tax_ID");
		BigDecimal TaxAmt	= Env.ZERO;
		

		
		BigDecimal GrossAmt = (BigDecimal)mTab.getValue("PayAmt");

		if (taxID != null)
		{
			int C_Tax_ID = taxID.intValue();
			MTax tax = new MTax (ctx, C_Tax_ID, null);
			TaxAmt = tax.calculateTax(GrossAmt, false, 2);
			mTab.setValue("TaxAmt", TaxAmt);
		}

		
		mTab.setValue("NetAmt", GrossAmt.subtract(TaxAmt) );
		
		
		return "";
		
	}
	

}
